package com.wc.AlgoOJ_train.train1.c4.A418;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/1/10 18:41
 * @description 分拆素数和
 * http://43.138.190.70:8888/p/A418
 */
public class Main {
    static boolean[] isNotPrime = new boolean[10050];
    static int[] primes = new int[10000];
    static int idx = 1;

    static void ola(int x) {
        isNotPrime[1] = true;
        for (int i = 2; i <= x; i++) {
            if (!isNotPrime[i]) {
                primes[idx++] = i;
            }
            for (int j = 1; primes[j] * i <= x; j++) {
                isNotPrime[primes[j] * i] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }

    public static void main(String[] args) {
        ola(10049);
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int num = sc.nextInt();
            if (num == 0) {
                return;
            }
            int mIdx = 1;
            int ans = 0;
            while (primes[mIdx] < num) {
                if (!isNotPrime[num - primes[mIdx]]) {
                    ans++;
                }
                mIdx++;
            }
            // 需要两个不同的素数和
            if (!isNotPrime[num / 2]) {
                ans--;
            }
            System.out.println(ans / 2);
        }
    }
}
